package com.dsp.week11.service;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.time.LocalDateTime;

@Component
public class Publisher {

    @Resource
    StringRedisTemplate stringRedisTemplate;

    @Value("${queue}")
    private String queue;


    public void pubMsg(String msg) {
        stringRedisTemplate.convertAndSend(queue, "I'm " + msg +
                ";Time:" + LocalDateTime.now());
    }
}
